	<script type="text/javascript">

	$(function(){
		var award = [
	<?php 
		foreach (Globals::award() as $key) {
			echo '"'. $key .'",';
		}
	?>
	];

		var alldata = new Array(
		<?php 
		foreach ($ret as $key) {
			echo '"'.$key->toCode().'",';
		}
		echo '"'.$ret[0]->toCode().'"'
		?>);
		var num = alldata.length - 1;
		var show = $("#show");
		var btn = $("#btn");
		var open = false;
	
		function change(){
			var randomVal = Math.round(Math.random() * num);
			var prizeName = alldata[randomVal];
			show.text(prizeName);
		}
		
		function run(){
			if(!open){
				timer=setInterval(change,100);
				btn.removeClass('start').addClass('stop').html("点击停止");
				open = true;
			}else{
				clearInterval(timer);
				btn.removeClass('stop').addClass('start').html("点击滚动抽奖");
				open = false;
				winning();
			}
		}
		
		btn.click(function(){run();})

		var winning = function(){
			if (show.text() == "") {
				$(".msg").html("没有要出奖号。");
				return;
			};

			$.get("<?php echo Yii::app()->homeUrl;?>?r=win/winning",{'ticket':show.text()},
				function(data){
					
					if (data instanceof Object) {
						if (data.code === 0) {
							var obj = data.data;
							if (obj != undefined ) {
								var str = "摇奖活动："+ obj.event + "<br>";
								str += "中奖人：" + obj.username + "<br>";
								str += "手机号：" + obj.mobile.substring(0,obj.mobile.length-4)  + "****<br>";
								if (obj.winning == 0) {
									str += "奖项：" + award[obj.winning] + "<br>";
								}else{
									str += "<span style='color:red;'>奖项：" + award[obj.winning] + "</span><br>";
								}
								str += "中奖时间：" + obj.wintime + "<br>";
								$(".msg").html(str);
								$('#ticket').val('');
							}else{
								$(".msg").html("没有找到奖券信息。");
							}
						}else{
							$(".msg").html(data.message);
						}
					}else{
						$(".msg").html($('#ticket').val() + "奖券输入不正确。");
					}

				},"json");
		}
		
	})
		
	</script>
	<style>
 	body
	{
		background-image: url(../server/css/bg2.png);
	}

	#content
	{
		margin: 15px auto;
		padding: 30px;
		width: 780px;
		background: #ffffff;
		background: -moz-linear-gradient(top,#FFFFFF 0%,#F2D0E6 99%);
		background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#FFFFFF),color-stop(99%,#F2D0E6));
		 
		-webkit-border-radius: 10px;
		border-radius: 10px;
	}

	#header img
	{
		width: 50%;
	}
	#footer #img2{
		width: 90%;
	}
	.show{ 
		width:751px; 
		height:264px; 
		background-image: url(../server/css/roll.png);
		text-align:center; 
		color:#fff; 
		font-size:70px; 
		line-height: 230px;
		margin: 10px auto;
	}
	.btn a{ 
		display:block; 
		width:524px; 
		height:108px; 
		margin:30px auto; 
		text-align:center; 
		 
		text-decoration:none; color:#fff; 
		-moz-border-radius:150px; 
		-webkit-border-radius:150px; 
		border-radius:150px;
		font-size:40px; 
		line-height: 100px;
	}
	.btn a.start{ 
		background-image: url(../server/css/button.png);
	}
	.btn a.start:hover{ }
	.btn a.stop{ 
		background-image: url(../server/css/button2.png);
	}
	.msg {
		color:#fff; 
		font-size:23px; 
		line-height: 35px;
		text-align: left;
		background-color: rgba(0,0,0,0.3);
		-moz-border-radius:5px; 
		-webkit-border-radius:5px; 
		border-radius:5px;
		padding: 10px;
		width: 500px;
		margin: 0 auto;
		margin-top: 20px;
		

	}
	</style>

<div class="wrap">
	<div class="show" id="show">点击按钮开始抽奖</div>
	<div class="btn">
		<a href="javascript:void(0)" class="start" id="btn">点击滚动抽奖</a>
	</div>
	<div class="msg">中奖信息</div>
</div>


